﻿using UnityEngine;
using System.Collections;

public class Projectile : MonoBehaviour {

	public float shootPow = 20;
	public GameObject explosionPrefab;

	public void ShootProjectile(Vector3 parentSpeed)
	{
		rigidbody.velocity = parentSpeed + transform.forward * shootPow;
	}

	void OnCollisionEnter(Collision coll)
	{
		GetComponentInChildren<TrailRenderer> ().autodestruct = true;
		GetComponentInChildren<TrailRenderer> ().transform.parent = null;
		GameObject.Instantiate (explosionPrefab, transform.position, Quaternion.identity);
		Destroy(gameObject);
	}
}
